package com.woniuxy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.daos.TbBedDao;
import com.woniuxy.entitys.TbBed;
import com.woniuxy.service.BedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BedServiceImpl implements BedService {
    @Autowired
    private TbBedDao tbBedDao;

    @Override
    public PageInfo<TbBed> getFreeBed(Integer hid,Integer did,Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<TbBed> list =tbBedDao.selectFreeBed(hid,did);
        PageInfo<TbBed> tbBedPageInfo = new PageInfo<>(list);
        return tbBedPageInfo;
    }

    @Override
    public List<TbBed> bedDetailsByDid(Integer did) {
        List<TbBed> list = tbBedDao.bedDetailsByDid(did);
        return list;
    }

    @Override
    public PageInfo<TbBed> getAll(int pageNum, int pageSize, String bnum, Integer hid, Integer did, Integer status) {
        PageHelper.startPage(pageNum,pageSize);
        List<TbBed> tbBeds = tbBedDao.selectSome(bnum, hid, did, status);
        PageInfo<TbBed> pageInfo = new PageInfo<>(tbBeds);
        return pageInfo;
    }

    @Override
    public List<TbBed> getBedByHidAndDid(Integer hid, Integer did) {
        return tbBedDao.selBedByHidAndDid(hid, did);
    }
    @Override
    public TbBed getBedById(Integer bid) {
        return tbBedDao.getBedById(bid);
    }

    @Override
    public int getallBed() {
        return tbBedDao.getallBed();
    }

}
